<html>
<head><meta charset="utf-8"><title>Add `--release` option for cargo publish/package · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html">Add `--release` option for cargo publish/package</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209352621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209352621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MaxV <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209352621">(Sep 08 2020 at 07:20)</a>:</h4>
<p>During package verification, cargo use default BuildConfig profile: <a href="https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_package.rs#L699">https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_package.rs#L699</a> which leads to <a href="https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/build_config.rs#L74">https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/build_config.rs#L74</a></p>
<p>Then cargo will use <code>debug</code> profile for verification.</p>
<p>As a developer I'll be happy to have the ability to specify which profile should be used. It'll help me to avoid extra building for the case where I already have all dependencies compiled for <code>release</code> profile.</p>
<p>I'm absolutely new for zulip, cargo's development process, etc.<br>
Please let me know if it is a wrong place for that kind of proposals and lead me to the correct one.</p>
<p>Everyone have a great day!<br>
MaxV</p>



<a name="209369279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209369279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209369279">(Sep 08 2020 at 10:34)</a>:</h4>
<p>do you mean that you want to build external crates in release mode ?</p>



<a name="209411768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209411768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209411768">(Sep 08 2020 at 16:33)</a>:</h4>
<p>It sounds like you're saying you want <code>cargo publish</code> and similar to verify in <code>--release</code> mode.</p>



<a name="209413188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209413188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209413188">(Sep 08 2020 at 16:45)</a>:</h4>
<p>Hm, I wonder if we could get Cargo to check the common profiles (debug and release) and just use whichever is closest to "done"</p>



<a name="209413293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209413293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209413293">(Sep 08 2020 at 16:46)</a>:</h4>
<p>I wouldn't like it to be non-deterministic though</p>



<a name="209413324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209413324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209413324">(Sep 08 2020 at 16:47)</a>:</h4>
<p>maybe non-deterministic is the wrong word - it should be obvious what it's doing</p>



<a name="209414090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209414090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209414090">(Sep 08 2020 at 16:52)</a>:</h4>
<p>Yeah, it should do a specific profile.</p>



<a name="209414122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209414122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209414122">(Sep 08 2020 at 16:53)</a>:</h4>
<p>If anything, I actually think it <em>should</em> build whichever one you haven't been using because then it'll be more likely to catch breakage. ;)</p>



<a name="209414142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209414142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209414142">(Sep 08 2020 at 16:53)</a>:</h4>
<p>Not that "it doesn't work in debug mode" is very common, but still.</p>



<a name="209414752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209414752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209414752">(Sep 08 2020 at 16:58)</a>:</h4>
<p>I thought <code>cargo publish</code> deliberately used a fresh <code>target</code> dir for the build test -- if nothing else to make sure it works with <a href="http://crates.io">crates.io</a> dependencies rather than local paths</p>



<a name="209414822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209414822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209414822">(Sep 08 2020 at 16:58)</a>:</h4>
<p>so this wouldn't use your existing <code>--release</code> artifacts anyway</p>



<a name="209415354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209415354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209415354">(Sep 08 2020 at 17:02)</a>:</h4>
<p>Yeah, I think it rebuilds from scratch even if things have been previously built.</p>



<a name="209417850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209417850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209417850">(Sep 08 2020 at 17:24)</a>:</h4>
<p>Ah, yeah, I think that's true. Probably also because presumably it uses a different feature resolver, one not affected by the workspace features?</p>



<a name="209424878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209424878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209424878">(Sep 08 2020 at 18:23)</a>:</h4>
<p>I've actually had projects that only work in release mode because of link errors when it's under-optimized</p>



<a name="209424919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209424919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209424919">(Sep 08 2020 at 18:23)</a>:</h4>
<p>though i could just turn up the opt-level on debug mode i suppose</p>



<a name="209427723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209427723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209427723">(Sep 08 2020 at 18:47)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Yeah, if you need a certain minimum optimization level to function, you should probably set that in the debug profile.</p>



<a name="209427816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209427816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209427816">(Sep 08 2020 at 18:48)</a>:</h4>
<p>I'm guessing it's that optimization turns a libcall into something inlined?</p>



<a name="209429199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Add%20%60--release%60%20option%20for%20cargo%20publish/package/near/209429199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Add.20.60--release.60.20option.20for.20cargo.20publish.2Fpackage.html#209429199">(Sep 08 2020 at 18:58)</a>:</h4>
<p>yep</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>